Skip to content

Document model pricing, the agent's per-session spend caps, and final cancels - #727

Open
DavidCockerill wants to merge 25 commits into
mainfrom
david/3040-agent-usage-budgets
Open

DavidCockerill wants to merge 25 commits into
mainfrom
david/3040-agent-usage-budgets

Conversation

@DavidCockerill

@DavidCockerill DavidCockerill commented Oct 12, 2026 •

Copy link
Copy Markdown
Member

⊙ Problem

agent: carry per-call token usage onto the session and enforce a budget (HarperFast/harper#3040) enforces the agent's maxCostUsd, adds agent.maxSessionTokens, session usage and model pricing, and makes a cancel final. The reference still calls maxCostUsd "not enforced", with a 5.00 default.

Refs HarperFast/harper#3040. Companion to Cap the agent's spend per session by tokens or priced cost, record its model usage, and make a cancel final (HarperFast/harper#3177).

🤔 Should these docs merge with the core PR?

Yes. They cover new config keys, a new response field, and changed status, 409 and cancel behavior that clients key on. Dated v5.4.0 to match the core milestone.

💡 Solution

🔧 Changes

✅ Verification

  • Every statement was checked against the core branch's code by cross-model review rounds.
  • npm run format:check passes.
  • The behavior these pages describe is exercised by the core PR's integrationTests/server/agent-budget.test.ts and its agent unit suites.

🤖 Generated by Claude Code (Anthropic Claude Opus 5.5); posted via @DavidCockerill.

Related PRs: #712 overlaps (merged here; agent.maxTokens in the same agent options, set_agent_config text and 5.4 notes), #717 overlaps (merged here; agent.configScope in the same agent options and set_agent_config text), #720 overlaps (merged here; agent.maxToolResultBytes in the same agent options and set_agent_config text), 2 others independent
Complexity: medium

Deferred findings

Review-Coverage: authored=claude; ran=gemini,codex; adjudicated=domain; blocked=cursor-composer(not-installed); declined=cursor-grok,cursor-kimi,cursor-muse,muse; rounds=14; full=3 @ 569af46

Review-Attention: skim ~2m (decisions: bare-cap-key-unsets, run-in-flight-node-local, structured-409-codes, auto-loop-unmeasured-fails-closed, session-scoped-budget, failed-calls-uncounted) @ 569af46

DavidCockerill and others added 16 commits October 6, 2026 12:47
Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a cap counts

agent.maxTokens is the per-reply output limit (#712). Also: a failed call
is never counted, an unmeasurable cap on a final answer ends completed, invalid caps fail the
agent's start, and auto-mode costUsd covers the final round.

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…efused approval does not run later

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… the 5.4 release notes

HarperFast/harper#3040 is milestoned v5.4, which is main, so it ships in 5.4.0 rather than a 5.3
patch.

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…t stays in the total

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…xact about costUsd and capped final answers

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…sts until restart, and note streaming is unpriced

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ishes

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… captured at run start

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… a mid-turn cancel answers the rest of the turn

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-727

This preview will update automatically when you push new commits.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the documentation for version 5.4.0, introducing model pricing, per-call cost tracking, and spend caps (maxSessionTokens and maxCostUsd) for the built-in agent. It also details updates to the operations API regarding session status, usage reporting, and cancellation behavior. The review feedback suggests using a VersionBadge to highlight the new costUsd field in the API documentation, and recommends splitting combined sentences in the tool-calling and operations guides to make fallback behaviors more distinct and readable.

Comment thread reference/models/api.md
Comment thread reference/models/tool-calling.md Outdated
Comment thread reference/operations-api/operations.md Outdated
DavidCockerill and others added 8 commits October 19, 2026 13:58
… spend caps

The agent's maxTokens, configScope and maxToolResultBytes docs landed in the same sections; the
set_agent_config key list, the captured-at-start list and the 5.4 Built-in Agent notes now carry all of
them. A reply the agent rejects as cut off or empty stays out of the transcript but its usage is kept
on the session (rejectedCalls) and counted. Two cancel and auto-loop sentences are split for scanning.

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…resend a prompt recorded but not run

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…is answered

Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Refs HarperFast/harper#3040

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…nly an approved one

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…that caps bound one session

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…g on an unmeasurable cap, and a bare maxTurns failing the start

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d what a bare cap key does

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown

🚀 Preview Deployment

Your preview deployment is ready!

🔗 Preview URL: https://preview.harper-documentation.harperfabric.com/pr-727

This preview will update automatically when you push new commits.

@DavidCockerill
DavidCockerill marked this pull request as ready for review October 19, 2026 23:42
@DavidCockerill
DavidCockerill requested a review from a team as a code owner October 19, 2026 23:42

This branch was successfully deployed

1 active deployment
pr-727 — 569af46a Deployed Oct 19, 2026 by github-actions[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant